﻿@model List<DMS.Models.BannerObject>
@{
    ViewBag.Title = "Danh sách Banner";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}


<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>Danh sách Banner</h2>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <table id="example" class="table table-striped responsive-utilities jambo_table">
                    <thead>
                        <tr class="headings">
                            <th>
                                <input type="checkbox" class="tableflat">
                            </th>
                            <th>Tên Banner</th>
                            <th>Nội dung Banner</th>
                            <th>Loại Banner</th>
                            <th>Vị trí</th>                            
                            <th>Ngày bắt đầu </th>
                            <th>Ngày kết thúc </th>
                            <th>Trạng thái </th>

                            <th class=" no-link last">
                                <span class="nobr">Action</span>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr class="even pointer">
                                <td class="a-center ">
                                    <input type="checkbox" class="tableflat" value="@item.BannerId">
                                </td>
                                <td class=" ">@item.BannerName</td>
                                <td class=" ">@Html.Raw(item.BannerContentDisplay)</td>
                                <td class=" ">@item.BannerTypeName</td>
                                <td class=" ">@item.BannerPositionName</td>
                                <td class=" ">@item.StartDate.ToString("dd/MM/yyyy")</td>
                                <td class=" ">@item.EndDate.ToString("dd/MM/yyyy")</td>
                                <td class=" ">
                                    <input type="checkbox" class="tableflat" @if (item.BannerActive) { <text> checked </text>  } />
                                </td>
                                <td class=" last">
                                    <a href="/admin/banneradd/@item.BannerId" class="btn btn-info btn-xs"><i class="fa fa-pencil"></i> Sửa </a>                                    
                                </td>
                            </tr>
                        }                       

                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <br />
    <br />
    <br />
</div>
@section Scripts {
    <script src="/assets/admin/js/datatables/js/jquery.dataTables.js"></script>
    <script src="/assets/admin/js/datatables/tools/js/dataTables.tableTools.js"></script>
    <script>
        $(document).ready(function () {
            $('input.tableflat').iCheck({
                checkboxClass: 'icheckbox_flat-green',
                radioClass: 'iradio_flat-green'
            });
        });
        var asInitVals = new Array();
        $(document).ready(function () {
            var oTable = $('#example').dataTable({
                "oLanguage": {
                    "sSearch": "Tìm kiếm:"
                },
                "aoColumnDefs": [
                    {
                        'bSortable': false,
                        'aTargets': [0]
                    } //disables sorting for column one
                ],
                'iDisplayLength': 20,
                "sPaginationType": "full_numbers",
                //"dom": 'T<"clear">lfrtip',
            });
            $("tfoot input").keyup(function () {
                /* Filter on the column based on the index of this element's parent <th> */
                oTable.fnFilter(this.value, $("tfoot th").index($(this).parent()));
            });
            $("tfoot input").each(function (i) {
                asInitVals[i] = this.value;
            });
            $("tfoot input").focus(function () {
                if (this.className == "search_init") {
                    this.className = "";
                    this.value = "";
                }
            });
            $("tfoot input").blur(function (i) {
                if (this.value == "") {
                    this.className = "search_init";
                    this.value = asInitVals[$("tfoot input").index(this)];
                }
            });
        });
    </script>
}